#ifndef _RECOPROXY_LOG_H_
#define _RECOPROXY_LOG_H_
//#include "spdlog/spdlog.h"
#include "spdlog/sinks/daily_file_sink.h"
#include <memory>
#include <stdarg.h>
#define LOGFILE
/*
 * #include "spdlog/sinks/stdout_color_sinks.h"
#include "spdlog/sinks/rotating_file_sink.h"

void multi_sink_example2()
{
    spdlog::init_thread_pool(8192, 1);
    auto stdout_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt >();
    auto rotating_sink = std::make_shared<spdlog::sinks::rotating_file_sink_mt>("mylog.txt", 1024*1024*10, 3);
    std::vector<spdlog::sink_ptr> sinks {stdout_sink, rotating_sink};
    auto logger = std::make_shared<spdlog::async_logger>("loggername", sinks.begin(), sinks.end(), spdlog::thread_pool(), spdlog::async_overflow_policy::block);
    spdlog::register_logger(logger);
}
#include "spdlog/sinks/daily_file_sink.h"
void daily_example()
{
    // Create a daily logger - a new file is created every day on 2:30am
    auto logger = spdlog::daily_logger_mt("daily_logger", "logs/daily.txt", 2, 30);
}

#include "spdlog/sinks/rotating_file_sink.h"
void rotating_example()
{
    // Create a file rotating logger with 5mb size max and 3 rotated files
    auto max_size = 1048576 * 5;
    auto max_files = 3;
    auto logger = spdlog::rotating_logger_mt("some_logger_name", "logs/rotating.txt", max_size, max_files);
}
 *
 *
 */
using namespace std;
//#define LOGFILE
#ifdef LOGFILE
namespace speech
{
class log
{
public:
	static log* getInstance()
	{
		std::call_once(m_flag,createInstance);
		return m_instance;
	}
	static void createInstance()
	{
		m_instance = new log();
	}
	static void destoryInstance()
	{
		delete m_instance;
	}
	shared_ptr<spdlog::logger>  getLog(){ return m_log; }

private:
	log(){
		 m_log = spdlog::daily_logger_mt("daily_logger","/var/log/recoProxy.log", 0, 00);
		 m_log->set_level(spdlog::level::debug);
	};
	log(const log& other); 
	shared_ptr<spdlog::logger> 	m_log; //for debug
	static log*                 m_instance;
	static std::once_flag       m_flag;
};
}

#endif
#endif
